package hypermediaresearch.controller.hypermedia;

import java.util.List;
/*
 * VinhJune 2012
 */
import hypermediaresearch.model.Partner;
import hypermediaresearch.model.Project;
import hypermediaresearch.service.PartnerService;
import hypermediaresearch.service.ProjectService;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;
import org.slim3.util.RequestMap;

public class Project_presentationController extends Controller {

    private ProjectService prjService = new ProjectService();
    private PartnerService ptnService = new PartnerService();
    
    @Override
    public Navigation run() throws Exception {
        String name = requestScope("name");
        String year = requestScope("year");
        requestScope("name", name);
        if (name != null){
            Project projectList = prjService.getProjectByName(name);
            requestScope("projectList", projectList);
            
            Partner coordinator = prjService.getCoordinator(name);
            requestScope("coordinator", coordinator);
                    
            List<Partner> partnerList = prjService.getPartnersByProject(name);
            requestScope("partnerList", partnerList);
            
            return forward("project_presentation.jsp");
        }
        if (year != null){
            List<Project> projectList = prjService.getProjectByYear(year);
            requestScope("projectList", projectList);
            return forward("projects_by_year.jsp");
        }
        return null;
        
        
        
    }
}
